<?php
class About extends Eloquent {

	protected $table = 'abouts';
    
    /**
     * get publish about show home page
     * @author Thuan Truong
     */
    public function getAboutById ($id) {
        return $this->whereRaw('id = ? and is_deleted = ?', array($id, 0))->first();
    }
    
    /**
     * get all about
     * @author Thuan Truong
     */
    public function getAllAbouts() {
        $abouts = About::where('is_deleted', '=', 0)->get();
        return $abouts;
    }
    
    /**
     * validate update about
     * @author Thuan Truong
     */
     
    
    /**
     * update about
     * @author Thuan Truong
     */
    public function updateAbouts ($input) {
        $email = About::find(1);
        $phone = About::find(2);
        $yahoo = About::find(3);
        $facebook = About::find(4);
        $address = About::find(5);
        $introduct = About::find(6);
        
        if (!empty($email)) {
            $email->description = $input['email'];
            $email->update();
        } 
        if (!empty($phone)) {
            $phone->description = $input['phone'];
            $phone->update();
        } 
		if (!empty($yahoo)) {
            $yahoo->description = $input['yahoo'];
            $yahoo->update();
        } 
		if (!empty($facebook)) {
            $facebook->description = $input['facebook'];
            $facebook->update();
        } 
		if (!empty($address)) {
            $address->description = $input['address'];
            $address->update();
        } 
		if (!empty($introduct)) {
            $introduct->description = $input['introduct'];
            $introduct->update();
        } 
    }

    
}